<?php



function member_favorites_block_content(){
    $act_day=date('Y-m-d');
    return get_offer_bydate($act_day);
}


function get_offer_bydate($act_day){
    global $user;
    $header = array(
	array('data' => 'Ajánlat neve', 'field' => 'block_offer'),
	array('data' => 'Ár', 'field' => 'block_price'),
    );
    $query = db_select('ep_favourite_offer', 'fo');
    $query->join('ep_offers', 'o', 'fo.oid = o.oid');
    $query->fields('fo',array('oid','uid'))
            ->fields('o',array('offer','price','oid','startdate'))
            ->condition('uid',$user->uid,'=')
            ->condition('startdate',$act_day,'=');
    $results = $query
            ->execute();
    $rows = array();
    foreach ($results as $favourite) {
    $rows[] = array(
	'data' => array(
           '<a href="'.url('member/offer_info/'.$favourite->oid).'">'.$favourite->offer.'</a>'.member_add_offer_to_favourite_control($favourite->oid),
           $favourite->price,
           )
        );
    }
    $html = theme('table', 
                array(
		 'header' => $header,
                 'rows'=>$rows,
		 'sticky' => TRUE,		
		 'empty' => t('Nincs elmentett ajánlat erre a napra'),
                 )
		);
     
        
   return $html;
}

